//
//  MonitorInfoFirstTableViewCell.m
//  ICrEAM
//
//  Created by kuroro on 16/11/2.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "MonitorInfoFirstTableViewCell.h"

@implementation MonitorInfoFirstTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (UIView *)SetUpHeaderViewWithID:(NSString *)ID name:(NSString *)name num:(NSString *)num cost:(NSString *)cost {
    
    [self.IDLabel removeFromSuperview];
    [self.nameLabel removeFromSuperview];
    [self.timeLabel removeFromSuperview];
    [self.costLabel removeFromSuperview];
    [self.lineView1 removeFromSuperview];
    [self.lineView2 removeFromSuperview];
    [self.lineView3 removeFromSuperview];
    [self.lineView4 removeFromSuperview];
    
    UIView *headerView = self.contentView;
    headerView.backgroundColor = [UIColor whiteColor];

    UILabel *IDLabel = [self createLabelWithText:ID textAlignment:NSTextAlignmentCenter];
    [headerView addSubview:IDLabel];
    [IDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(headerView.mas_left);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(ActualWidth(280)));
    }];
    UIView *lineView1 = [[UIView alloc]init];
    lineView1.backgroundColor = SepColor_gray;
    [headerView addSubview:lineView1];
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(IDLabel.mas_right).offset(-1);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(1));
    }];
    
    UILabel *nameLabel = [self createLabelWithText:name textAlignment:NSTextAlignmentCenter];
    [headerView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(IDLabel.mas_right);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(ActualWidth(270)));
    }];
    
    UIView *lineView2 = [[UIView alloc]init];
    lineView2.backgroundColor = SepColor_gray;
    [headerView addSubview:lineView2];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(nameLabel.mas_right).offset(-1);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(1));
    }];
    
    UILabel *timeLabel = [self createLabelWithText:[NSString stringWithFormat:@"%@",num] textAlignment:NSTextAlignmentCenter];
    [headerView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(nameLabel.mas_right);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(ActualWidth(110)));
    }];
    UIView *lineView3 = [[UIView alloc]init];
    lineView3.backgroundColor = SepColor_gray;
    [headerView addSubview:lineView3];
    [lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(timeLabel.mas_right).offset(-1);
        make.bottom.equalTo(headerView.mas_bottom);
        make.width.equalTo(@(1));
    }];
    
    UILabel *costLabel = [self createLabelWithText:[NSString stringWithFormat:@"%@",cost] textAlignment:NSTextAlignmentCenter];
    [headerView addSubview:costLabel];
    [costLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top);
        make.left.equalTo(timeLabel.mas_right);
        make.bottom.equalTo(headerView.mas_bottom);
        make.right.equalTo(headerView.mas_right);
    }];
    
    UIView *lineView4 = [[UIView alloc]init];
    lineView4.backgroundColor = SepColor_gray;
    [headerView addSubview:lineView4];
    [lineView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top).offset(1);
        make.left.equalTo(headerView.mas_left);
        make.right.equalTo(headerView.mas_right);
        make.height.equalTo(@(1));
    }];
    
    self.IDLabel = IDLabel;
    self.nameLabel = nameLabel;
    self.timeLabel = timeLabel;
    self.costLabel = costLabel;
    self.lineView1 = lineView1;
    self.lineView2 = lineView2;
    self.lineView3 = lineView3;
    self.lineView4 = lineView4;
    
    return headerView;
}

- (UILabel *)createLabelWithText:(NSString *)text  textAlignment:(NSTextAlignment)textAlignment{
    UILabel *label = [[UILabel alloc] init];
    label.text = text;
    label.font = ContentFont;
    label.textColor = ContentTextColor_Black;
    label.textAlignment = textAlignment;
    return label;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
